<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询考勤</title>
<link rel="icon" href="<c:url value='/imgs/logo.ico' />" />
<link type="text/css" rel="stylesheet" href="<c:url value='/css/index.css' />" />
<link type="text/css" rel="stylesheet" href="<c:url value='/css/add.css' />" />
<script type="text/javascript" charset="utf-8" src="<c:url value='/scripts/jquery-2.1.0.js'/>"></script>
<script charset="utf-8" src="<c:url value='/scripts/laydate.js' />"></script>
</head>
<body onload="init()">
	<div class="container">
		<%@ include file="/jsps/top.jsp"%>
		<div class="main">
			<c:if test="${errorNum > 0 }">
				<div class="errorNote"><a href="queryRunresult?type=2&pc=1">存在异常日期,点击查看详情</a></div>
			</c:if>
			<c:if test="${errorNum==0||empty errorNum }">
				<div class="errorNote" style="visibility:hidden;">&nbsp;</div>
			</c:if>
			<form class="form attend">
<%-- 			<form class="form attend" action="<c:url value='/queryErrorsheet' />" method="get"> --%>
				<h2>查询考勤</h2>
				<table>
					<c:if test="${sessionScope.employee.power eq '0' }">
					<tr>
						<td><label>机&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;构：</label></td>
						<td>
							<select name="mechid" class="select">
								<option selected value="">&nbsp;&nbsp;全部机构</option>
								<c:forEach items="${mechanismList }" var="mechanism">
									<option value="${mechanism.mechid }">&nbsp;&nbsp;${mechanism.mechname }</option>
								</c:forEach>
							</select>
						</td>
					</tr>
					<tr>
						<td><label>工&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label></td>
						<td>
							<input class="txt" type="text" name="empid"  placeholder="请输入工号" />
						</td>
					</tr>
					</c:if>
					<tr>
						<td><label>查询类型：</label></td>
						<td>
							<label class="ctxt"><input class="chose" type="radio" name="cxtype" value="E" checked onclick="show()"/>异常</label>
							<label class="ctxt"><input class="chose" type="radio" name="cxtype" value="F" onclick="hide()"/>流水</label>
						</td>
					</tr>
					<tr>
						<td><label>开始日期：</label></td>
						<td>
							<input id="date1" class="txt" type="text" name="bdate" placeholder="请输入开始日期" />
						</td>
					</tr>
					<tr>
						<td></td>
						<td>
							<span class="error error1"></span>
						</td>
					</tr>
					<tr>
						<td><label>结束日期：</label></td>
						<td>
							<input id="date2" class="txt" type="text" name="edate"  placeholder="请输入结束日期" />
						</td>
					</tr>
					<tr>
						<td></td>
						<td>
							<span class="error error2"></span>
						</td>
					</tr>
					<tr class="tjtype">
						<td><label>工作类型：</label></td>
						<td>
							<label class="ctxt"><input class="chose" type="radio" name="tjtype" value="W"/>正常</label>
							<label class="ctxt"><input class="chose" type="radio" name="tjtype" value="H"/>加班</label>
						</td>
					</tr>
				</table>
				<input class="btn queryBtn" type="button" value="查询"/>
				<input class="btn" type="reset" value="重置"/>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		function init(){
			var cxtype = $("input[name='cxtype']:checked").val();
			if(cxtype=='F'){
				hide()
			}
		}
	
		function show(){
			$(".main .form .tjtype").css("display","table-row");
		}
		
		function hide(){
			$(".main .form .tjtype").css("display","none");
		}
	
		$(function(){
			//日期选择器
			laydate.render({
				elem: '#date1' //指定元素
			});
			laydate.render({
				elem: '#date2'
			});
			
			$(".top .title").click(function(){
				location.href="<c:url value='/index.jsp'/>";
			});	
			
			$(".main .form .queryBtn").click(function(){
				var mechid = $("select[name='mechid']").val();
				var empid = $("input[name='empid']").val();
				var bdate = $("input[name='bdate']").val();
				var edate = $("input[name='edate']").val();
				var tjtype = $("input[name='tjtype']:checked").val();
				var cxtype = $("input[name='cxtype']:checked").val();

				var flag = true;
				if(typeof(empid)!="undefined"){//若是管理员登录，则验证流水工号
					if(cxtype=="F"&&$.isEmptyObject(empid.trim())){
						flag=false;
						alert("查询流水须输入工号!");
					}
				}else{
					empid=${sessionScope.employee.empid };
					mechid="";
				}
				
				if(typeof(tjtype)=="undefined"){
					tjtype="";
				}
				
				if(flag){
					window.location.href="/faceattendsystem/queryErrorsheet?mechid="+mechid+"&empid="+empid+"&bdate="+bdate+"&edate="+edate+"&tjtype="+tjtype+"&cxtype="+cxtype+"&type=1&pc=1";
				}
			});
		})
	</script>
</body>
</html>